<div class="breadcrumbs ace-save-state" id="breadcrumbs">
	<ul class="breadcrumb">
		<li>
			<i class="ace-icon fa fa-list"></i>
			<a href="javascript:void(0)">系统配置</a>
		</li>
		<li class="active">溯码后台配置</li>
	</ul><!-- /.breadcrumb -->

	<div class="nav-search" id="nav-search">
		<form class="form-search">
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off"/>
                <i class="ace-icon fa fa-search nav-search-icon"></i>
            </span>
		</form>
	</div><!-- /.nav-search -->
</div>

<div class="page-content">

	<div class="row" id="page_wxmp_config_list">
		<div class="col-xs-12">
			<!-- PAGE CONTENT BEGINS -->
			<table id="wxmp-config-grid-table"></table>
			<div id="wxmp-config-grid-pager"></div>
			<!-- PAGE CONTENT ENDS -->
		</div><!-- /.col -->

	</div><!-- /.row -->

	<div class="row" id="page_wxmp_config_detail">


	</div>
</div><!-- /.page-content -->


<script type="text/javascript">

	user_page_init();

	function user_page_init() {
		var grid_selector = "#wxmp-config-grid-table";
		var pager_selector = "#wxmp-config-grid-pager";

		// 初始化
		var grid_config ={{ grid_config|safe }};

		function style_edit_form_field(form) {
		}

		// 操作列
		function formatMyAc(cellValue, options, rowObject, state) {
			var detail = '<div title="详情" style="float:left;cursor:pointer;" ' +
				'class="ui-pg-div ui-inline-edit"' +
				'onclick="showWxmpConfigDetail(' + rowObject.id + ');" ' +
				'onmouseover="jQuery(this).addClass(\'ui-state-hover\');" ' +
				'onmouseout="jQuery(this).removeClass(\'ui-state-hover\');">' +
				'<span class="ui-icon ui-icon-pencil"></span>' +
				'</div>';

			var del = '<div title="删除" style="float:left;cursor:pointer;" ' +
				'class="ui-pg-div ui-inline-del"' +
				'onclick="jQuery.fn.fmatter.rowactions.call(this,\'del\');" ' +
				'onmouseover="jQuery(this).addClass(\'ui-state-hover\');" ' +
				'onmouseout="jQuery(this).removeClass(\'ui-state-hover\');">' +
				'<span class="ui-icon ui-icon-trash"></span>' +
				'</div>';

			return '<div style="margin-left:8px;">' + detail + del + '</div>'
		}

		JqGridHelp.updateColModel(grid_config, "myac", {formatter: formatMyAc});
		var jqGridHelp = JqGridHelp.createNew(grid_selector, pager_selector, grid_config, style_edit_form_field, {edit: true, add: true, del: true, search: true, refresh: true, view: true});
	}

	// 显示配置详情
	function showWxmpConfigDetail(id) {
		var detail_page = $('#page_wxmp_config_detail');

		function callback(data, status, xhr) {
			if (status == "success") {
				detail_page.html(data);
			} else {
				detail_page.html("错误信息: <br/>" + xhr.status + " " + xhr.statusText)
			}
			$('#page_wxmp_config_list').hide();
			detail_page.show();
		}

		$.get("/smAdmin/sysconf/smadmin_conf_detail", {id: id}, callback);
	}

	// 返回，显示配置列表
	function ShowPageWxmpConfigList() {
		$('#page_wxmp_config_list').show();
		$('#page_wxmp_config_detail').hide();
		// 重新加载信息
		reloadConfigDataList();
	}

	/**
	 * 重新配置牌列表信息
	 */
	function reloadConfigDataList() {
		var filters = {"groupOp": "AND", "rules": []};
		var rules = filters.rules;
		//var args = formserializeJson("brand_list_form");
		//for (var name in args) {
		//	var value = args[name];
		//	if (value) {
		//		rules.push({field: name, op: "cn", data: value});
		//	}
		//}
		var postData = $(grid_selector).jqGrid("getGridParam", "postData");
		$.extend(postData, {filters: JSON.stringify(filters)});
		$(grid_selector).jqGrid("setGridParam", {search: true}).trigger("reloadGrid", [{page: 1}]);  //重载JQGrid
	}

</script>